﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Entity;
using Meqs.Logic.Interface;
using System.Collections.Generic;
public partial class Score_Education_AreaManage_ViewApplySchool : System.Web.UI.Page
{
    protected int currExamId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected int GetClassNum(string schoolMark)
    {
        int examId = 0, num = 0;
        string s = txtExamId.Text;
        if (!String.IsNullOrEmpty(s))
        {
            if (int.TryParse(s, out examId))
                examId = Convert.ToInt32(s);
        }

        if (examId > 0)
        {
            IExamClassEducationLogic examClassLogic = Container<IExamClassEducationLogic>.Instance;
            Hashtable table = new Hashtable();
            table.Add("ExamID", examId);
            table.Add("SchoolMark", schoolMark);

            List<ExamClassEducation> list = new List<ExamClassEducation>();
            list = (List<ExamClassEducation>)examClassLogic.FindAll(table);
            num = list.Count;
        }
        return num;
    }


    //初始化 repeat控件，集成显示教师关联信息
    protected void btnBind_Click(object sender, EventArgs e)
    {
        int examId = 0;
        string s = txtExamId.Text;
        if (!String.IsNullOrEmpty(s))
        {
            if (int.TryParse(s, out examId))
                examId = Convert.ToInt32(s);
        }
        currExamId = examId;
        if (currExamId > 0)
        {
            List<SchoolInfo> listSchool = new List<SchoolInfo>();
            IExamClassEducationLogic examClassLogic = Container<IExamClassEducationLogic>.Instance;

            Hashtable table = new Hashtable();
            table.Add("ExamID", examId);
            List<ExamClassEducation> listExamClass = (List<ExamClassEducation>)examClassLogic.FindAll(table);
            ISchoolInfoLogic logic = Container<ISchoolInfoLogic>.Instance;

            List<string> listSchoolMark = new List<string>();
            foreach (ExamClassEducation item in listExamClass)
            {
                if (!listSchoolMark.Contains(item.SchoolMark))
                {
                    table = new Hashtable();
                    table.Add("SchoolMark", item.SchoolMark);
                    if (CommonScore.GetAreaID > 0)
                        table.Add("AreaID", CommonScore.GetAreaID);
                    listSchool.AddRange(logic.FindAll(table));
                    listSchoolMark.Add(item.SchoolMark);
                }
            }


            Repeater1.DataSource = listSchool;
            Repeater1.DataBind();
        }
    }

}
